// 导入router包
const Router = require('koa-router')
// 实例化对象
const OrderRouter = new Router({ prefix: '/orders' })
// 权限中间件
const { auth } = require('../middleware/auth.middleware')
// 参数校验
const { paramValidator } = require('../middleware/order.middleware')
// 添加购物车
const { create, findAll, update } = require('../controllers/order.controllers')
// 提交订单
OrderRouter.post('/', auth, paramValidator(
    {
        address_id: "int",
        goods_info: "string",
        total: 'string'
    }
), create)
// 获取订单列表
OrderRouter.get('/', auth, findAll)
// 修改订单状态
OrderRouter.patch('/:id', auth, paramValidator({
    state: 'number'
}), update)
module.exports = OrderRouter